<%@ page import="java.util.Date" %>
<%@ page import="util.DateUtil" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<div class="panel panel-info">
        <div class="panel-heading">
            <h3 class="panel-title" style="display: inline-block">查询</h3>
        </div>
        <div class="panel-body">
        <div class="form-horizontal row">
            <form id="form_automatic">
                <div class="form-group col-sm-5 ">
                    <label class="col-sm-4 control-label">专家数量：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="number" name="count" value="5">
                    </div>
                </div>
                <div class="form-group col-sm-5 ">
                    <label class="control-label col-sm-4">组长类型：</label>
                    <div class="col-sm-8">
                        <select class="form-control" name="leaderGradeList" multiple>
                            <option selected value="AA">AA</option>
                            <option value="A">A</option>
                            <option value="B">B</option>
                            <option value="C">C</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-5">
                    <label class="col-sm-4 control-label">所属单位：</label>
                    <div class="col-sm-8">
                        <%--<input class="form-control" type="text" name="affiliateCompany">--%>
                        <select class="form-control" id="affiliateCompanyAuto" name="affiliateCompany">
                            <option value="">&nbsp;</option>
                        </select>
                    </div>
                </div>

                <%
                    java.text.SimpleDateFormat simpleDateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd");
                    java.util.Date currentTime = new java.util.Date();
                    String startTime = simpleDateFormat.format(currentTime).toString();
                    String endTime= simpleDateFormat.format(DateUtil.moveDate(currentTime,30)).toString();
                %>

                <div class="form-group col-sm-5">
                    <label class="col-sm-4 control-label">开始时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date form_date  timeInput">
                                                <span class="input-group-addon">
                                                    <span class="glyphicon glyphicon-calendar"></span>
                                                </span>
                            <input class="form-control " type="text" id="startTime_2" name="startTime"
                                   value="<%=startTime%>">
                        </div>
                    </div>
                </div>
                <div class="form-group col-sm-5">
                    <label class="col-sm-4 control-label">结束时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date form_date  timeInput">
                                                <span class="input-group-addon">
                                                    <span class="glyphicon glyphicon-calendar"></span>
                                                </span>
                            <input class="form-control" type="text" id="endTime_2" name="endTime" value="<%=endTime%>">
                        </div>
                    </div>
                </div>
                <div class="form-group col-sm-5">
                    <div class="col-sm-8 col-sm-offset-4">
                        <button type="button" id="btn_automatic"
                                class="btn btn-default   ">
                            <span class="glyphicon glyphicon-search"></span>&nbsp;抽&nbsp;取&nbsp;
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<table id="table_automatic"></table>

<script>
    $(function () {

        $.sysPlugin.initSelect2($("#affiliateCompanyAuto"), {
            url: '${base}/httpPage/affiliateCompanyOnlyLive',
        });


        $btn_automatic.click(function () {
            var date1 = new Date(Date.parse($("#startTime_2").val().replace("-", "/")));
            var date2 = new Date(Date.parse($("#endTime_2").val().replace("-", "/")));
            if (date1 > date2) {
                alert("开始时间不能小于结束时间");
                return;
            }
           $table_automatic.bootstrapTable('refresh');
        });


        $table_automatic.bootstrapTable({
            url: '${base}/httpPage/gongXu/automaticExtractionExpert',
            striped: true,
            cache: false,
            sidePagination: 'client',
            pagination: true,
            queryParams: function (params) {

                $.extend(params, $("#form_automatic").serializeObject());
                if ( !params.leaderGradeList){
                    alert("组长类型不能为空");
                    return;
                }

                params.businessCode = '${business.businessCode}';
                params.leaderGradeList=params.leaderGradeList&&params.leaderGradeList.toString();
                return params;
            },
            columns: [
                {
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    title: '姓名',
                    field: 'name',
                    formatter: function (value, row, index) {
                        return [
                            '<div class="nameClick" ><a href="javascript:;" style="text-decoration: none ;display: block;width: 60px">' + value + '</a></div>'
                        ].join('');
                    },
                    events: 'events'
                },

                {
                    field: 'idCard',
                    title: '身份证号码',
                    visible: false
                },
                {
                    field: 'grade',
                    title: '专家类型'
                },
                {
                    field: 'phone',
                    title: '手机号码'
                },
                {
                    field: 'workCompany',
                    title: '单位',
                    visible: false
                },
                {
                    field: 'affiliateCompany',
                    title: '所属单位'
                },
                {
                    field: 'reviewTimes',
                    title: '今年审查（评审）次数'
                },
                {
                    field: 'result',
                    title: '结果',
                    formatter: function (value, row, index) {
                        if (value == true) {
                            return '能去';
                        } else {
                            return '不能去';
                        }
                    }
                },
                {
                    field: 'reason',
                    title: '备注'
                },
                {
                    title: '操作',
                    events: 'events',
                    field: 'leader',
                    formatter: function (value, row, index) {
                        if (index == 0) {
                            return [
                                '<button  type="button" class="btn btn-xs btn-default  checkLeader ">' +
                                '<span class="glyphicon glyphicon-check  "></span> 全选' +
                                '</button>'
                            ].join('');
                        }
                    }
                }
            ]
        });

    });


</script>




